home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / p / pofo / sprachen / vtlisp / vtlisp.doc < prev    next >
Encoding:
Text File  |  1991-08-21  |  6.5 KB  |  173 lines

  1.                         VT-LISP - Very Tiny LISP
  2.  
  3.  
  4. VT-LISP  Version 2.0  is  a  simple functional LISP interpreter  provided  
  5. with   full  source    code  to  encourage  experimentation  with   LISP, 
  6. functional and object oriented languages.
  7.  
  8. Startup
  9.  
  10. 1. Boot the system.
  11. 2. Insert the disk containing VTLISP.COM in Drive A:
  12. 3. If the DOS prompt is not A>, type A: and press the ENTER key to switch
  13.    to drive A:.
  14. 4. Type VTLISP and press RETURN. VTLISP should respond with its heading
  15.    and a '-> ' prompt.
  16.  
  17. Entering S-expressions.
  18.  
  19. VT-LISP  accepts S-expressions,  evaluates them and prints the result  of
  20. the evaluation.  You enter an S-expression by typing it directly from the
  21. keyboard.  As you enter S-expressions,  the prompt may change to a number
  22. followed  by  '>'.   The  number  represents  the  number  of   unmatched
  23. parentheses. For example:
  24.  
  25.      VT-LISP -  Copyright 1987 [c] Knowledge Garden Inc.
  26.      -> (cons 'a '(b c))
  27.      (a b c )
  28.      -> (letrec (append '(a b c) '(d e f))
  29.      1>    (append (lambda (x y)
  30.      3>      (if (eq x nil) y
  31.      4>         (cons (car x) (append (cdr x) y))))))
  32.      (a b c d e f )
  33.      ->(read 'b:append)  ; read and evaluate the file b:append.lsp
  34.  
  35. Terminating VT-LISP
  36.  
  37. 1. To exit VT-LISP, type :
  38.           (exit) 
  39.    at the '-> ' prompt.
  40.  
  41. VT-LISP Grammar
  42.  
  43.    The following BNF describes the syntax of S-expressions
  44.  
  45. S-expression ::- atom | '(' expression-list ')'
  46. atom ::- text-string | number
  47. expression-list ::- S-expression | S-expression '.' S-expression |
  48.                     S-expression expression-list
  49.  
  50. VT-LISP expressions
  51.  
  52. Variable
  53. x  - upper or lower case identifier, returns the value x if x is bound
  54.  
  55. Constants
  56. (QUOTE s) - returns s
  57. 's
  58.  
  59. Arithmetic  expressions - expr1,expr2 are evaluated before  operation  is 
  60.                           performed.
  61. (ADD expr1 expr2)  (+ expr1 expr2)
  62. (SUB expr1 expr2)  (- expr1 expr2)
  63. (MUL expr1 expr2)  (* expr1 expr2)
  64. (DIV expr1 expr2)  (/ expr1 expr2)
  65. (MOD expr1 expr2)
  66.  
  67. Comparisons - expr1,expr2 are evaluated before  comparison  is 
  68.                           performed.
  69. (EQ expr1 expr2) - returns T if expr1 evaluates to the same thing as expr2
  70. (= expr1 expr2)
  71. (LT expr1 expr2) - returns T if expr1 < expr2
  72. (< expr1 expr2)
  73. (GT expr1 expr2) - returns T if expr1 > expr2
  74. (> expr1 expr2)
  75. (NEQ expr1 expr2) - returns T if expr1 <> expr2
  76. (<> expr1 expr2)
  77. (LE expr1 expr2) - returns T if expr1 <= expr2
  78. (<= expr1 expr2)
  79. (GE expr1 expr2) - returns T if expr1 >= expr2
  80. (>= expr1 expr2)
  81.  
  82. S-expression  operations  - expr1,  expr2 evaluated before  operation  is 
  83.                             performed
  84. (CONS expr1 expr2) - returns dottted pair (expr1.expr2)
  85. (CAR expr) - returns first element of expr
  86. (CDR expr) - returne list formed by removing 1st element from expr
  87. (ATOM expr) - returns T if expr evaluates to an atom
  88.  
  89. Conditional expression
  90. (IF expr1 expr2 expr3) - If expr1 returns T, evaluate expr2, otherwise
  91.                          evaluate expr3
  92.  
  93. Return to DOS
  94. (EXIT)
  95.  
  96. Read an expression from a file
  97. (READ expr) - read an expression from file expr. expr must evaluate to an
  98.               atom which is represents a file name.  File names must  end
  99.               in ".LSP". Example: (read 'b:append)
  100. (LOAD expr) - read an entire file.  expr must evaluate to an
  101.               atom which is represents a file name.  File names must  end
  102.               in ".LSP". Example: (read 'b:append). Returns the result of
  103.               the last expression evaluated. This is a convenient method
  104.               of reading in a bunch of DEFUNs at the beginning of a session.
  105.  
  106. Definition expressions
  107. (LAMBDA (x1 x2 x3 ....) expr) - define a lambda expression - returns a
  108.                                 closure repreenting the lambda expression 
  109.                                 bound to the current environment
  110. (LET  expr (x1.expr1) (x2.expr2) .......) - define a block.  x1 etc.  are
  111.                local variables. expr1, expr2 etc are their deinitions. 
  112.                expr1,  expr2 etc.  are evaluated in current environment, 
  113.                independently of one another.
  114. (LETREC expr (x1.expr1) (x2.expr2) ......) - define a recursive block.
  115.                expr1, expr2 etc. may contain references to one another
  116. (DEFUN name (x1 x2 ....) expr) - define a global function. Note - the
  117.              sloppy method we have used does not allow nested DEFUNs.
  118.              DEFUN returns the name of the function that has been evaluated.
  119.  
  120. Function Call
  121. (expr  expr1  expr2  expr3  ...)  - evaluate  the  function  expr,  using
  122.                                     parameters expr1 etc.  Parameters are
  123.                                     evaluated before applying the function.
  124.                                     expr must evaluate to a closure.
  125.  
  126. Object oriented features
  127. (make object_name inheritance_list 
  128.      (method_selector1 method1) (method_selector2 method2) ....)
  129.           - define an object, inheritance_list is a list of object names 
  130.             from which this object inherits methods. None of these 
  131.             parameters are evaluated before object is added to the list 
  132.             of objects.
  133.  
  134. (send object_name method_selector) - retreive the value of 
  135.             method_selector from object_name and evaluate it.
  136.  
  137. (send object_name method_selector arg1 arg2 ...) - retrieve the value of 
  138.             method_selector from object_name, evaluate the returned value 
  139.             and args in the extended environment. The value of 
  140.             method_selector should evaluate to a closure. For example,
  141.             (make test (obj1 obj2)
  142.                   (cost (lambda (x y) (* x y))))
  143.             and sending the message (send test cost 12 23) will return 
  144.             35.
  145.  
  146. (send object_name expr) - evaluate expr in the extended environment 
  147.             constructed by object_name's inheritance.
  148.  
  149. Comments
  150. ;  - comments begin with ";". Anything following ";" on a line is ignored
  151.      by the evaluator
  152.  
  153. Pressing <Ctrl-Break> will abort the current operation and return you to 
  154. the '->' prompt.
  155.  
  156.            
  157. Good   luck  with VT-LISP.   We would be very interested in  hearing   of
  158. your  experiments,   enhancements or even (gasp) bugs that you may  find.
  159. Please write to us with your comments or questions.
  160.  
  161.      Bill and Bev Thompson
  162.      C/O AI Expert Magazine
  163.      500 Howard St.
  164.      San Francisco, CA 94105
  165.  
  166. or  on  the AI Expert BBS on Compuserv.  Our id is BillandBev Thompson,
  167. [76703,4324]. You can also contact us on BIX, our id is bbt.
  168.  
  169.    Bill and Bev Thompson
  170.  
  171.  
  172.  
  173.